package com.sun.opne;

import java.util.List;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TextView;
import com.sun.base.UserActivity;
import com.sun.lotter.R;
import com.sun.net.LinkServer;
import com.sun.net.BaseDao.HttpListener;
import com.tools.SysInterfacePhone;

public class OpenLotterInfoDetail extends UserActivity
{

	
	private TableLayout tablelayout;
	private ProgressBar progressBar;
	private ScrollView scrollView;
	/**  开奖期号**/
	private TextView textView1;//
	/** 开奖时间 **/
	private TextView textView2;//
	/** 开奖号码 **/
	private TextView textView3;//
	/** 本期总投注金额 **/
	private TextView textView4;//
	/** 本期奖池金额 **/
	private TextView textView5;//

	@Override
	public void init()
	{
		setTitle("开奖信息详情");
		SysInterfacePhone.invoker().setViewBackground(this, titleLayout, "titlebackground.png");
		inflater.inflate(R.layout.openlotterinfodetail, mainLayout);
		tablelayout = (TableLayout) mainLayout.findViewById(R.id.tableLayout2);
		progressBar = (ProgressBar) mainLayout.findViewById(R.id.progressBar);
		scrollView = (ScrollView) mainLayout.findViewById(R.id.scrollView);
		scrollView.setVisibility(View.GONE);
		textView1 = (TextView) mainLayout.findViewById(R.id.textView1);
		textView2 = (TextView) mainLayout.findViewById(R.id.textView2);
		textView3 = (TextView) mainLayout.findViewById(R.id.textView3);
		textView4 = (TextView) mainLayout.findViewById(R.id.textView4);
		textView5 = (TextView) mainLayout.findViewById(R.id.textView5);
		getdata();
	}

	public void getdata()
	{
		LinkServer ls = new LinkServer(handler);
		ls.SearchKaiJiangDetail(lotterId, getIntent().getStringExtra("expect"), new HttpListener()
		{

			@Override
			public void onEvent(List<String> list)
			{
				progressBar.setVisibility(View.GONE);
				if (!LinkServer.servertrue(list))
				{
					SysInterfacePhone.invoker().createDialog(OpenLotterInfoDetail.this, "开奖详情加载失败").show();
					return;
				}
				scrollView.setVisibility(View.VISIBLE);
				textView1.setText(list.get(2));
				textView2.setText(list.get(4));
				textView3.setText(list.get(3));
				textView4.setText(list.get(5));
				textView5.setText(list.get(6));
				String str3 = list.get(7);// 奖项
				String str4 = list.get(8);// 中奖注数
				String str5 = list.get(9);// 每注奖金
				String[]info1 = str3.split(",");
				String[]info2 = str4.split(",");
				String[]info3 = str5.split(",");
				inflater.inflate(R.layout.openlotterinfodetail_item, tablelayout);
				for (int i = 0; i < info1.length; i++)
				{
					View view = inflater.inflate(R.layout.openlotterinfodetail_item, null);
					((TextView)view.findViewById(R.id.textView1)).setText(info1[i]);
					((TextView)view.findViewById(R.id.textView2)).setText(info2[i]);
					((TextView)view.findViewById(R.id.textView3)).setText(info3[i]);
					tablelayout.addView(view);
				}
			}
		});
	}
}
